package models

type Pages struct {
	Rows    int         `json:"rows"`
	CurrentPage int         `json:"current_page"`
	TotalPage   int64       `json:"total_page"`
	Data        interface{} `json:"data"`
	Total       int64       `json:"total"`
}

func NewPages(page, rows int, total int64, data interface{}) *Pages {
	var totalPage int64
	if total == 0 {
		totalPage = 0
	} else {
		if total%int64(rows) > 0 {
			totalPage = total/int64(rows) + 1
		} else {
			totalPage = total / int64(rows)
		}
	}
	return &Pages{
		Rows:    rows,
		CurrentPage: page,
		TotalPage:   totalPage,
		Data:        data,
		Total:       total,
	}
}
